package com.zp.datax.core;


import com.zp.datax.core.model.DataxJobTrigger;

import java.time.Instant;

/**
 * 条件处理器
 *
 * @author bruce
 * @date 2019-07-15
 */
public abstract class Condition {


    protected Condition condition;
    private DataxJobTrigger dataxJobTrigger;

    protected Condition() {

    }

    protected Condition(DataxJobTrigger dataxJobTrigger) {
        this.dataxJobTrigger = dataxJobTrigger;
    }

    protected Condition(Condition condition) {
        if (condition != null) {
            this.condition = condition;
            this.dataxJobTrigger = condition.dataxJobTrigger;
        }
    }

    /**
     * Object[] obj = new Object[5];
     * <p/>
     * obj[0]=过虑条件
     * <p/>
     * obj[1]=当前时间
     *
     * @return
     */
    protected Object[] append() {
        return new Object[]{"", Instant.now().toEpochMilli()};
    }

    protected abstract Object[] append(String strCondition) throws IllegalArgumentException;

    protected DataxJobTrigger getDataxJobTrigger() {
        return dataxJobTrigger;
    }

    protected Object[] getObjarray(String str) {
        if (condition != null) {
            return condition.append(str);
        } else {
            return append();
        }
    }

}
